<?php
class Stock_receipt_model extends CI_Model
{
	public $tbl = 'stock_receipt';

	public function __contruct()
	{
		parent::__construct();	
	}

	public function All($warehouseId)
	{
		$queryString = "SELECT * FROM stock_receipt WHERE WarehouseId = $warehouseId ORDER BY Id DESC";

		$query = $this->db->query($queryString);
		
		return $query->result();
	}

	public function GetWarehouseId($receiptId)
	{
		$queryString = "SELECT * FROM stock_receipt WHERE Id = $receiptId ORDER BY Id DESC";

		$query = $this->db->query($queryString);
		
		return $query->row()->WarehouseId;
	}	

	public function Add($warehouseId, $employeeId)
	{
		$data = array(
			'WarehouseId' => $warehouseId,
			'EmployeeId' => $employeeId,
			'Note' => $this->input->post('Note'),
			'Date' => date('Y-m-d H:i:s')
			);

		return $this->db->insert($this->tbl, $data);
	}	
}
?>